import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
    mete: {
      auth: true
    }
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

// 进入页面前 
// vue-router4   router.beforeEach 中的next参数可以省略  return false
// router.beforeEach((to, from, next) => {
//   if (to.path === '/about') {
//     next('/404')
//   }
//   next()
// })

export default router
